package com.dream.usercenter.domain.service.query;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dream.usercenter.domain.persistence.po.UcSettings;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

									
/**
 * <p>
 * 配置信息
 * 查询条件类  由模板自动生成
 * </p>
 *
 * @author liuyj
 * @since 2022-07-23 19:01:30
 */
public class UcSettingsQueryBo{
	/**
	 * 排序，批量查询
	 */
	private QueryBoExt queryBoExt;
	/**
	 * 模糊查询
	 */
	private List<QueryBoFuzzy> queryBoFuzzyList;
	/**
	 * 主键ID
	 */
	private Long id;

	/**
	 * 配置名称
	 */
	private String setName;

	/**
	 * 编码
	 */
	private String setCode;

	/**
	 * 配置值
	 */
	private String setValue;

	/**
	 * 描述
	 */
	private String desc;

	/**
	 * 平台ID
	 */
	private Long platId;

	/**
	 * 
	 */
	private LocalDateTime createDateTime;

	/**
	 * 
	 */
	private LocalDateTime updateDateTime;

	/**
	 * 
	 */
	private LocalDate createDate;


	/**
	 * 构建查询
	 * @return
	 */
	public QueryWrapper<UcSettings> buildQuery() {
		QueryWrapper<UcSettings> query = new QueryWrapper<>();

		if(id!=null){
			query.eq(UcSettings.ID,id);
		}
		if(setName!=null){
			query.eq(UcSettings.SET_NAME,setName);
		}
		if(setCode!=null){
			query.eq(UcSettings.SET_CODE,setCode);
		}
		if(setValue!=null){
			query.eq(UcSettings.SET_VALUE,setValue);
		}
		if(desc!=null){
			query.eq(UcSettings.DESC,desc);
		}
		if(platId!=null){
			query.eq(UcSettings.PLAT_ID,platId);
		}
		if(createDateTime!=null){
			query.eq(UcSettings.CREATE_DATE_TIME,createDateTime);
		}
		if(updateDateTime!=null){
			query.eq(UcSettings.UPDATE_DATE_TIME,updateDateTime);
		}
		if(createDate!=null){
			query.eq(UcSettings.CREATE_DATE,createDate);
		}
	
		//模糊查询
		if(queryBoFuzzyList!=null && queryBoFuzzyList.size()>0){
			for (QueryBoFuzzy queryBoFuzzy : queryBoFuzzyList) {
				if(queryBoFuzzy.getValue()==null || queryBoFuzzy.getValue().trim().length()==0){
					continue;
				}
				query.or(blogsQueryWrapper -> {
					blogsQueryWrapper.like(queryBoFuzzy.getColumn(),queryBoFuzzy.getValue().trim());
				});
			}
		}
		if(queryBoExt!=null){
			//设置排序
			if(queryBoExt.getOrderColumn()!=null && queryBoExt.getOrderColumn().trim().length()>0 ){
				if(queryBoExt.isAsc()){
					query.orderByAsc(queryBoExt.getOrderColumn());
				}else{
					query.orderByDesc(queryBoExt.getOrderColumn());
				}
			}
			//批量的查询条件进行查询
                        if(queryBoExt.getIdList()!=null && queryBoExt.getIdList().size()>0){
                query.in(UcSettings.ID,queryBoExt.getIdList());
            }
                        if(queryBoExt.getSetNameList()!=null && queryBoExt.getSetNameList().size()>0){
                query.in(UcSettings.SET_NAME,queryBoExt.getSetNameList());
            }
                        if(queryBoExt.getSetCodeList()!=null && queryBoExt.getSetCodeList().size()>0){
                query.in(UcSettings.SET_CODE,queryBoExt.getSetCodeList());
            }
                        if(queryBoExt.getSetValueList()!=null && queryBoExt.getSetValueList().size()>0){
                query.in(UcSettings.SET_VALUE,queryBoExt.getSetValueList());
            }
                        if(queryBoExt.getDescList()!=null && queryBoExt.getDescList().size()>0){
                query.in(UcSettings.DESC,queryBoExt.getDescList());
            }
                        if(queryBoExt.getPlatIdList()!=null && queryBoExt.getPlatIdList().size()>0){
                query.in(UcSettings.PLAT_ID,queryBoExt.getPlatIdList());
            }
                        if(queryBoExt.getCreateDateTimeList()!=null && queryBoExt.getCreateDateTimeList().size()>0){
                query.in(UcSettings.CREATE_DATE_TIME,queryBoExt.getCreateDateTimeList());
            }
                        if(queryBoExt.getUpdateDateTimeList()!=null && queryBoExt.getUpdateDateTimeList().size()>0){
                query.in(UcSettings.UPDATE_DATE_TIME,queryBoExt.getUpdateDateTimeList());
            }
                        if(queryBoExt.getCreateDateList()!=null && queryBoExt.getCreateDateList().size()>0){
                query.in(UcSettings.CREATE_DATE,queryBoExt.getCreateDateList());
            }
            		}
		return query;
	}

		
	public Long getId() {
        return id;
	}

	public void setId(Long id) {
        this.id = id;
    }
		
	public String getSetName() {
        return setName;
	}

	public void setSetName(String setName) {
        this.setName = setName;
    }
		
	public String getSetCode() {
        return setCode;
	}

	public void setSetCode(String setCode) {
        this.setCode = setCode;
    }
		
	public String getSetValue() {
        return setValue;
	}

	public void setSetValue(String setValue) {
        this.setValue = setValue;
    }
		
	public String getDesc() {
        return desc;
	}

	public void setDesc(String desc) {
        this.desc = desc;
    }
		
	public Long getPlatId() {
        return platId;
	}

	public void setPlatId(Long platId) {
        this.platId = platId;
    }
		
	public LocalDateTime getCreateDateTime() {
        return createDateTime;
	}

	public void setCreateDateTime(LocalDateTime createDateTime) {
        this.createDateTime = createDateTime;
    }
		
	public LocalDateTime getUpdateDateTime() {
        return updateDateTime;
	}

	public void setUpdateDateTime(LocalDateTime updateDateTime) {
        this.updateDateTime = updateDateTime;
    }
		
	public LocalDate getCreateDate() {
        return createDate;
	}

	public void setCreateDate(LocalDate createDate) {
        this.createDate = createDate;
    }


	public List<QueryBoFuzzy> getQueryBoFuzzyList() {
		return queryBoFuzzyList;
	}

	public void setQueryBoFuzzyList(List<QueryBoFuzzy> queryBoFuzzyList) {
		this.queryBoFuzzyList = queryBoFuzzyList;
	}

	public QueryBoExt getQueryBoExt() {
		return queryBoExt;
	}

	public void setQueryBoExt(QueryBoExt queryBoExt) {
		this.queryBoExt = queryBoExt;
	}

	/**
	* 模糊查询的字段 - 注意，是全模糊
	*/
	public static class QueryBoFuzzy {
		/**
		 * 字符名称 - 数据库的
		 */
		private String column;
		/**
		 * 值
		 */
		private String value;

		public String getColumn() {
			return column;
		}

		public void setColumn(String column) {
			this.column = column;
		}

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		@Override
		public String toString() {
			final StringBuilder sb = new StringBuilder("QueryBoFuzzy{");
			sb.append(super.toString());
			sb.append(",");
			sb.append("                column='").append(column).append('\'');
			sb.append(",                 value='").append(value).append('\'');
			sb.append('}');
			return sb.toString();
		}
	}
    /**
    * 用于排序，和批量的查询
    */
    public static class QueryBoExt {
		/**
		 * 一般情况下只需要单个列的排序
		 */
		private String orderColumn;

		/**
		 * 默认正序
		 */
		private boolean asc = true;

		        /**
         * 主键ID
         * 集合
         */
        private List<Long> idList;
		        /**
         * 配置名称
         * 集合
         */
        private List<String> setNameList;
		        /**
         * 编码
         * 集合
         */
        private List<String> setCodeList;
		        /**
         * 配置值
         * 集合
         */
        private List<String> setValueList;
		        /**
         * 描述
         * 集合
         */
        private List<String> descList;
		        /**
         * 平台ID
         * 集合
         */
        private List<Long> platIdList;
		        /**
         * 
         * 集合
         */
        private List<LocalDateTime> createDateTimeList;
		        /**
         * 
         * 集合
         */
        private List<LocalDateTime> updateDateTimeList;
		        /**
         * 
         * 集合
         */
        private List<LocalDate> createDateList;
		

                public List<Long> getIdList() {
            return idList;
        }

        public void setIdList(List<Long> idList) {
            this.idList = idList;
        }
                public List<String> getSetNameList() {
            return setNameList;
        }

        public void setSetNameList(List<String> setNameList) {
            this.setNameList = setNameList;
        }
                public List<String> getSetCodeList() {
            return setCodeList;
        }

        public void setSetCodeList(List<String> setCodeList) {
            this.setCodeList = setCodeList;
        }
                public List<String> getSetValueList() {
            return setValueList;
        }

        public void setSetValueList(List<String> setValueList) {
            this.setValueList = setValueList;
        }
                public List<String> getDescList() {
            return descList;
        }

        public void setDescList(List<String> descList) {
            this.descList = descList;
        }
                public List<Long> getPlatIdList() {
            return platIdList;
        }

        public void setPlatIdList(List<Long> platIdList) {
            this.platIdList = platIdList;
        }
                public List<LocalDateTime> getCreateDateTimeList() {
            return createDateTimeList;
        }

        public void setCreateDateTimeList(List<LocalDateTime> createDateTimeList) {
            this.createDateTimeList = createDateTimeList;
        }
                public List<LocalDateTime> getUpdateDateTimeList() {
            return updateDateTimeList;
        }

        public void setUpdateDateTimeList(List<LocalDateTime> updateDateTimeList) {
            this.updateDateTimeList = updateDateTimeList;
        }
                public List<LocalDate> getCreateDateList() {
            return createDateList;
        }

        public void setCreateDateList(List<LocalDate> createDateList) {
            this.createDateList = createDateList;
        }
        
        public String getOrderColumn() {
			return orderColumn;
		}

		public void setOrderColumn(String orderColumn) {
			this.orderColumn = orderColumn;
		}

		public boolean isAsc() {
			return asc;
		}

		public void setAsc(boolean asc) {
			this.asc = asc;
		}
	}


}
